"""tm URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include
from rest_framework import routers
from rest_framework.documentation import include_docs_urls

from django.conf.urls.static import static

from tm.settings import MEDIA_URL, MEDIA_ROOT

from user import views as UserViews
from user.views import *
from menu import views as MenuViews
from menu.views import *
from gold import views as GoldViews
from gold.views import *
from events import views as EventsViews
from events.views import *

router = routers.DefaultRouter()
# 用户管理user
router.register(r'register', UserViews.Register, basename='register')                        #用户注册
router.register(r'exists', UserViews.Exists, basename='exists')                              #用户注册和忘记密码验证账号
router.register(r'self', UserViews.UserSelfViewSet, basename='self')                         #用户个人信息
router.register(r'user', UserViews.UserViewSet, basename='user')                             #用户信息
router.register(r'user-option', UserViews.UserOptionViewSet1, basename='user-option')          #用户下拉1
router.register(r'user-option', UserViews.UserOptionViewSet2, basename='user-option')          #用户下拉2
router.register(r'portraits', UserViews.PortraitViewSet, basename='portraits')               #用户头像
router.register(r'addressed', UserViews.AddressHistoricalViewSet, basename='addressed')      # 用户历史地址
router.register(r'address', UserViews.AddressViewSet, basename='address')                    # 地址
router.register(r'address-option', UserViews.AddressOptionViewSet, basename='address-option')  # 地址下拉选
router.register(r'label', UserViews.LabelViewSet , basename='label')                         # 标签
router.register(r'label-option', UserViews.LabelOptionViewSet , basename='label-option')       # 标签下拉选
router.register(r'label2user', UserViews.LabelToUserViewSet , basename='label2user')         # 标签指向用户
router.register(r'label2user-option', UserViews.LabelToUserOptionViewSet , basename='label2user-option')# 标签指向用户下拉选
router.register(r'invite', UserViews.InviteViewSet , basename='invite')                        # 邀请码
router.register(r'forget', UserViews.UserForgetViewSet, basename='forget')                   #忘记密码登记
router.register(r'data2user', UserViews.DataToUserViewSet, basename='data2user')             #用户信息
router.register(r'groups', UserViews.GroupViewSet, basename='groups')                                  #分组
router.register(r'group-option', UserViews.GroupOptionViewSet, basename='group-option')                #分组下拉选
router.register(r'permission-option', UserViews.PermissionOptionViewSet, basename='permission-option') #权限下拉选

# 菜单模块管理menu
router.register(r'module', MenuViews.ModuleViewSet, basename='module')                                 #菜单
router.register(r'module-option', MenuViews.ModuleOption, basename='module-option')                    #菜单下拉选
router.register(r'project', MenuViews.ProjectViewSet, basename='project')                              #模块
router.register(r'project-option', MenuViews.ProjectOptionViewSet, basename='project-option')          #项目模块下拉选

# 金币管理gold
router.register(r'tmgold', GoldViews.TMgoldViewSet, basename='tmgold')  
router.register(r'tmgold-option', GoldViews.TMgoldOptionViewSet, basename='tmgold-option')  
router.register(r'tmgold2event', GoldViews.TMgoldToEventViewSet, basename='tmgold2event')  
router.register(r'tmgold2event-option', GoldViews.TMgoldToEventOptionViewSet, basename='tmgold2event-option')  
router.register(r'allgold', GoldViews.AllGoldViewSet, basename='allgold')  

# 事件管理events
router.register(r'event-img', EventsViews.EventImgViewSet, basename='event-img')  
router.register(r'event-img-option', EventsViews.EventImgOptionViewSet, basename='event-img-option')  
router.register(r'event-type', EventsViews.EventTypeViewSet, basename='event-type')  
router.register(r'event-type-option', EventsViews.EventTypeOptionViewSet, basename='event-type-option')  
router.register(r'comment', EventsViews.CommentViewSet, basename='comment')  
router.register(r'comment-option', EventsViews.CommentOptionViewSet, basename='comment-option')  
router.register(r'event', EventsViews.EventViewSet, basename='event')  


urlpatterns = [
    path('', include(router.urls)),
    path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
    path('admin/', admin.site.urls),
    path('docs/', include_docs_urls(title="Time mercenaries")),
    path('login/', UserViews.Login.as_view(), name='my_token'),
] + static(MEDIA_URL, document_root=MEDIA_ROOT)